package main

func main() {

}

type ListNode struct {
    Val int
    Next *ListNode
}

func getIntersectionNode(headA, headB *ListNode) *ListNode {
	hashMap := make(map[*ListNode]bool)
	for ; headA != nil; {
		hashMap[headA] = true
		headA = headA.Next
	}
	for ; headB != nil; {
		if hashMap[headB] {
			return headB
		}
		headB = headB.Next
	}
	return nil
}